package com.chencs.utils;

import com.chencs.biz.Common;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import org.jsoup.Jsoup;

public class GetKouLing {


    /**
     * 获取口令
     * @param title
     * @param url
     * @return
     */
    public static String  kouling(String title,String url,String imgurl){
        TaobaoClient client = new DefaultTaobaoClient(Common.apiUrl + "taobao.tbk.tpwd.create", Common.appKey, Common.appSecre);
        TbkTpwdCreateRequest req = new TbkTpwdCreateRequest();
        req.setUserId("{\"pid\":\"1212121\"}");
        req.setText(title);
        req.setUrl(url+"&pid=1212121");
        req.setLogo(imgurl);
        req.setExt("{\"pid\":\"1212121\"}");
        req.setPid("1212121");
        String code ="";
        try {
            TbkTpwdCreateResponse rsp = client.execute(req);
            System.out.println(rsp.getBody());
        }catch (Exception e){
            e.printStackTrace();
        }
        return code;
    }

    /**
     * 轻淘客拿券
     * @param sid
     * @param gid
     * @return
     */
    public static String QingTaoKe2(String sid,String gid) {
        String str2 = "-1";
        try {
            org.jsoup.nodes.Document res1 = Jsoup.connect("http://www.qingtaoke.com/api/UserPlan/UserCouponList")
                    .data("gid", gid)
                    .data("sid", sid)
                    .timeout(40000).ignoreContentType(true).post();
            str2 = res1.body().text();
        } catch (Exception e) {
            e.printStackTrace();
            return "-1";
        }
        return str2;
    }



    public static void main(String[] args) {

       // System.out.println(GetKouLing.QingTaoKe2("479184430","561752318341"));

        System.out.println(GetKouLing.kouling("测试测试测试测试","https://uland.taobao.com/coupon/edetail?e=onC1Iij6eaYGQASttHIRqVdjWK5qPTHIM7VRAsychb%2BcCWxV4QYCqFO7729C6Yojf6DCjihW%2FRFbOF%2BQang2FZBh%2BsFgnewCdlqVZQ6Dswst%2FzOJQMDvl9ssii%2F7skwC","http://inews.gtimg.com/newsapp_bt/0/3543877817/640"));

    }
}
